package com.timothy.android;


import com.timothy.service.MessageSender;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class LoginActivity extends Activity {
	/** Called when the activity is first created. */
	private EditText hostAddr = null;
	private EditText hostPort = null;
	private Button loginBtn = null;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		
		hostAddr = (EditText) this.findViewById(R.id.hostAddr);
		hostPort = (EditText) this.findViewById(R.id.hostPort);
		
		loginBtn = (Button) this.findViewById(R.id.loginBtn);
		loginBtn.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v) {
//				MessageSender.PC_IP =  hostAddr.getText().toString();
//				MessageSender.PC_PORT = Integer.valueOf( hostPort.getText().toString() );
				//Send Phone Information to PC
//				if( MessageSender.sendMessage( MessageSender.Get_Base_Stations ) ) {
					Intent intent = new Intent();
				    intent.setClass(LoginActivity.this, BaseStations.class);
				    startActivity(intent);
//				} else {
//					ShowDialog("不能连接到指定IP的端口，请重新设置");
//				}	
			}			
		});
	}
	
	public void ShowDialog(String msg) {
		new AlertDialog.Builder(this).setTitle("提示")
		                             .setMessage(msg)
				                     .setPositiveButton("OK", new DialogInterface.OnClickListener() {
										                    	  public void onClick(DialogInterface dialog, int which) {
										                    		  hostAddr.performClick();
										                    	  }
										                      })
				                     .show();
	}
	
	
}
